package com.eos.control.action.customer;

import com.eos.business.service.SysCustomerBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysCustomer;
import com.eos.orm.mybatis.model.SysUser;

public class DeleteCustomerAction extends AbstractBaseAction {
	private static final long serialVersionUID = -1590849528577451846L;
    private Integer customerId;
	
	public void setCustomerId(Integer customerId) {
		this.customerId = customerId;
	}


	@Override
	public String execute() {
		 try {
			if(null == customerId || customerId.intValue() <= 0){
				statusCode = "300";
				message = "参数错误,删除供应商失败!";
			}else{
				SysUser user = (SysUser) getSession().getAttribute("SysUser");
				SysCustomerBusinessService scbs = new SysCustomerBusinessService();
				SysCustomer customer = new SysCustomer();
				customer.setId(customerId);
				customer.setDealFlag(ConstantTool.DEAL_FLAG_FAIL);
				customer.setModifyTime(ObjectUtils.formatDate(null, "yyyy-MM-dd HH:mm:ss"));
				customer.setUpdateUserId(user.getId()+"");
				String exeStatus = scbs.updateCustomerSelective(customer);
				if("SUCCESS".equals(exeStatus)){
					statusCode = "200";
					message = "删除客户信息成功!";
				}else{
					statusCode = "300";
					message = "系统繁忙, 删除客户信息失败!";
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常,删除客户信息失败!";
		}
		return SUCCESS;
	}
}
